﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Text.RegularExpressions;

namespace WinFormAssigment.BUS
{
    class Validation
    {
        public static bool IsEmptyTextBox(TextBox[] arrTextBox) {
            for (int i = 0; i < arrTextBox.Length; i++)
            {
                if (arrTextBox[i].Text.Trim().Length == 0) {
                    return true;
                }
            }
            return false;
        }
        public static bool IsEmptyRichTextBox(RichTextBox[] arrRichTextBox) {
            for (int i = 0; i < arrRichTextBox.Length; i++)
            {
                if (arrRichTextBox[i].Text.Trim().Length == 0) {
                    return true;
                }
            }
            return false;
        }
        public static bool ValidationTeacherDOB(DateTime dob)
        {
            int y1 = Convert.ToInt32(dob.ToString("yyyy"));
            int y2 = Convert.ToInt32(DateTime.Now.ToString("yyyy"));
            int result = y2 - y1;
            if (result > 17)
            {
                return true;
            }
            else return false;

        }
        
        public static bool IsPhoneNumber(string text) {
            Regex regex = new Regex("^[0-9]+$");
            return regex.IsMatch(text);
        }
        public static bool IsValidEmail(string text) {
            Regex regex = new Regex("^\\w+@\\w\\D+(\\.\\w\\D+)+");
            return regex.IsMatch(text);
        }

        public static bool rdbNotChecked(RadioButton[] arrRadioButtons)
        {
            for (int i = 0; i < arrRadioButtons.Length; i++)
            {
                if (arrRadioButtons[i].Checked)
                {
                    return false;
                }
            }
            return true;
        }
    }
}
